using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing.Ansi
{
	internal class OracleLpTableReferenceAnsiJoinedTable : OracleLpTableReferenceAnsi
	{
		protected OracleLpJoinedTable m_vJoinedTable;

		public override List<OracleLpColumnDescriptor> ColumnDescriptors => m_vJoinedTable.ColumnDescriptors;

		public OracleLpJoinedTable JoinedTable
		{
			get
			{
				return m_vJoinedTable;
			}
			set
			{
				m_vJoinedTable = value;
				if (m_vJoinedTable != null)
				{
					m_vJoinedTable.Parent = this;
				}
			}
		}

		internal override List<OracleLpTablePrimary> TablePrimaryList
		{
			get
			{
				if (m_vTablePrimaryList == null)
				{
					m_vTablePrimaryList = new List<OracleLpTablePrimary>();
					m_vTablePrimaryList.AddRange(JoinedTable.TableReference.TablePrimaryList);
					m_vTablePrimaryList.AddRange(JoinedTable.JoinClause.TablePrimaryList);
				}
				return m_vTablePrimaryList;
			}
		}

		public OracleLpTableReferenceAnsiJoinedTable(OracleLpStatementElement se)
			: base(se)
		{
			m_vTableReferenceType = OracleLpTableReferenceAnsiType.JoinedTable;
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			sb.Append(depthIndent);
		}

		public override void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			m_vJoinedTable.RetrieveNamedObjectReferences(statement);
		}
	}
}
